﻿<%@ WebHandler Language="C#" Class="SIPO.Web.AjaxHandler.Loaddata.validasibynpwpjenisusahaunion" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.Enum;
using SIPO.Web.Support;
using Newtonsoft.Json.Linq;
using System.Text;
namespace SIPO.Web.AjaxHandler.Loaddata
{

    public class validasibynpwpjenisusahaunion : SIPO.Web.BaseHandler
    {
        recDebtorSectorRepo recDebtorSectorDal = new recDebtorSectorRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);
            string snpwp = context.Request.Params["npwp"].ToString().Trim();
            int isectorId = Convert.ToInt32(context.Request.Params["sectorId"]);
            int isubSectorId = Convert.ToInt32(context.Request.Params["subSectorId"]);
            int isubSubSectorId = Convert.ToInt32(context.Request.Params["subSubSectorId"]);

            string npwp = string.Empty;
            int sectorId = 0;
            int subSectorId = 0;
            int subSubSectorId = 0;
            recDebtorSector recDebtorSector = null;
            recDebtorSector = recDebtorSectorDal.GetByNPWPAndSectorUnion(snpwp, isectorId, isubSectorId, isubSubSectorId);
            if (recDebtorSector != null)
            {
                npwp = recDebtorSector.recDebtor.NPWP;
                sectorId = recDebtorSector.SectorID;
                subSectorId = recDebtorSector.SubSectorID;
                subSubSectorId = recDebtorSector.SubSubSectorID;
            }

            StringBuilder sbProject = new StringBuilder();
            sbProject.Append("{");
            sbProject.AppendFormat("  {0}NPWP{0}:{0}{1}{0}", "\"", npwp);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}SectorID{0}:{0}{1}{0}", "\"", sectorId);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}SubSectorID{0}:{0}{1}{0}", "\"", subSectorId);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}SubSubSectorID{0}:{0}{1}{0}", "\"", subSubSectorId);
            sbProject.Append("}");

            context.Response.Write(sbProject.ToString());
        }
        
        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}